package edu.scau.mis.pos.service.impl;

import edu.scau.mis.pos.domain.Promotion;
import edu.scau.mis.pos.mapper.PromotionMapper;
import edu.scau.mis.pos.service.IPromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PromotionServiceImpl implements IPromotionService {
    @Autowired
    private PromotionMapper promotionMapper;
    @Cacheable(value = "listAllPromotion",key = "#root.methodName")
    @Override
    public List<Promotion> selectList() {
        return promotionMapper.selectList();
    }

    @Override
    public List<Promotion> selectByPage(Promotion params) {
        return promotionMapper.selectByPage(params);
    }

    @Override
    public int deletePromotion(String promotionId) {
        return promotionMapper.deletePromotion(promotionId);
    }
    @Override
    public int addPromotion(Promotion promotion) {
        return promotionMapper.insert(promotion);
    }
    @Override
    public int updatePromotion(Promotion promotion) {
        return promotionMapper.update(promotion);
    }

    @Override
    public List<Promotion> getPromotionsByTypeAndStatus(String type) {
        return promotionMapper.selectByTypeAndStatus(type);
    }

    @Override
    public Promotion selectPromotionById(String promotionId) {
        return promotionMapper.selectPromotionById(promotionId);
    }


}
